//app.js

import {ajax} from "./utils/httpRequest.js";
import {URI_LOGIN} from "./api.js";

App({
  onLaunch: function () {
    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        let code = res.code;

        ajax.post(URI_LOGIN,{
          code:code,
        },{},res=>{
          wx.setStorageSync('access_token',res.data.access_token);
          wx.setStorageSync('userId',res.data.id);
        })


        //console.log(code);
      }
    })

  }
})